<?php

namespace App\Http\Controllers;

use App\Utils\Curl;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;

class LoginController extends Controller
{

    //登录
    public function login(Request $request)
    {
        $request->merge(Config('site.auth'));
        return Curl::sendPostRequest(null,$request->all(), Config('site.gate_root').'/s/user/login');

    }

    public function sendRegisterSmsCode(Request $request)
    {
        return Curl::sendPostRequest(null,$request->all(), Config('site.gate_root').'/s/user/sms/register');
    }

    public function sendResetSmsCode(Request $request)
    {
        return Curl::sendPostRequest(null,$request->all(), Config('site.gate_root').'/s/user/sms/password');
    }

    //注册
    public function register(Request $request) {
        return Curl::sendPostRequest(null,$request->all(), Config('site.gate_root').'/s/user/register');
    }

    //重置密码
    public function resetPassword(Request $request) {
        return Curl::sendPostRequest(null,$request->all(), Config('site.gate_root').'/s/user/password/reset');
    }

    //获取用户信息
    public function getUserDetail(Request $request) {
        $header =  [ 'Authorization: '.$request->header('Authorization') ];
        return Curl::sendGetRequest($header, Config('site.gate_root').'/s/user');
    }
}
